package com.tyk.bookstore.front.order.model.vo;


import com.tyk.bookstore.front.common.core.model.enume.PaymentWay;
import com.tyk.bookstore.front.common.core.model.vo.PageVo;
import com.tyk.bookstore.front.common.core.util.FileUtil;
import com.tyk.bookstore.front.order.model.emume.OrderState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author tyk
 * @description OrderPageVo
 */
@Data
public class OrderPageVo extends PageVo<OrderPageVo.Order> {
    @Data
    public static class Order {

        @Schema(description = "ID")
        private Long id;

        @Schema(description = "订单号")
        private String orderNo;

        @Schema(description = "商品总金额")
        private BigDecimal amount;

        @Schema(description = "下单时间")
        private LocalDateTime createTime;

        @Schema(description = "订单状态[0待支付,1待发货,2待取件,3已完成,4已取消,5已拆单]")
        private OrderState state;

        @Schema(description = "收件人姓名")
        private String cneeName;

        @Schema(description = "支付方式[0商城余额，1支付宝，2微信]")
        private PaymentWay paymentWay;

        @Schema(description = "是否可以评价")
        private Boolean commentAble;

        @Schema(description = "订单详情(当且仅当childList为null)")
        private List<OrderDetail> detailList;

        @Schema(description = "子订单(当且仅当detailList为null)")
        private List<Order> childList;
    }

    @Data
    public static class OrderDetail {

        @Schema(description = "ID")
        private Long id;

        @Schema(description = "书籍ID")
        private Long bookId;

        @Schema(description = "书籍编号")
        private String bookNo;

        @Schema(description = "书籍封面")
        private String cover;

        @Schema(description = "书籍标题")
        private String title;

        @Schema(description = "购买数量")
        private Long num;

        @Schema(description = "评论ID")
        private Long commentId;

        public OrderDetail setCover(String cover) {
            this.cover = FileUtil.fullFilePath(cover);
            return this;
        }
    }
}